import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '订单编号',
    dataIndex: 'orderId',
    width: 120,
    align: 'center',
  },
  {
    title: '预定时间',
    dataIndex: 'bookTime',
    width: 120,
    align: 'center',
  },
  {
    title: '预定人',
    dataIndex: 'bookerName',
    width: 60,
    align: 'center',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    align: 'center',
    customRender: ({ text }) => {
      if (text === '0') {
        return h(Tag, { color: 'blue' }, () => '原始订单');
      } else if (text === '1') {
        return h(Tag, { color: 'blue' }, () => '已出票');
      } else if (text === '2') {
        return h(Tag, { color: 'pink' }, () => '出票失败');
      } else if (text === '3') {
        return h(Tag, { color: 'pink' }, () => '无效订单');
      } else if (text === '4') {
        return h(Tag, { color: 'pink' }, () => '确认改签中');
      }
    },
  },
  {
    title: '审批单号',
    dataIndex: 'travelId',
    width: 150,
    align: 'center',
  },
  {
    title: '出发地',
    dataIndex: 'fromStation',
    width: 120,
    align: 'center',
  },
  {
    title: '目的地',
    dataIndex: 'arriveStation',
    width: 120,
    align: 'center',
  },
  {
    title: '车次',
    dataIndex: 'trainCode',
    width: 90,
    align: 'center',
  },
  {
    title: '席别',
    dataIndex: 'seatTypeDes',
    width: 70,
    align: 'center',
  },
  {
    title: '支付状态',
    dataIndex: 'payStatus',
    width: 80,
    align: 'center',
    customRender: ({ text }) => {
      if (text === '0') {
        return h(Tag, { color: 'red' }, () => '未支付');
      } else if (text === '1') {
        return h(Tag, { color: 'green' }, () => '已支付');
      }
    },
  },
  {
    title: '总金额',
    dataIndex: 'totalMoney',
    width: 60,
    align: 'right',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderId',
    label: '订单号',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'trainCode',
    label: '预定车次',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 220px',
    },
  },
  {
    field: 'accountNo',
    label: '员工编号',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'bookerName',
    label: '员工姓名',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'createTime',
    component: 'RangePicker',
    label: '预定日期',
    colProps: {
      span: 6,
    },
    componentProps: {
      placeholder: ['预定日期起', '预定日期止'],
      style: 'width: 220px',
    },
  },

  {
    field: 'fromStation',
    label: '出发车站',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'arriveStation',
    label: '到达车站',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
];
